package br.ufmg.ubicomp.droidguide.eventservice.event;

import br.ufmg.ubicomp.droidguide.common.Device;
import br.ufmg.ubicomp.droidguide.eventservice.enums.EventState;
import br.ufmg.ubicomp.droidguide.eventservice.enums.EventType;
import br.ufmg.ubicomp.droidguide.utils.DateUtil;

/**
 * class that defines the user events in the droid guide system
 * events comming from device to server
 * @author wpjr
 *
 */

public class UserEvent extends DroidGuideEvent implements Comparable<UserEvent>{

	private String description;
	private EventState state;
	private EventType type;
	private boolean sentToServer;
	
	

	public boolean isSentToServer() {
		return sentToServer;
	}



	public void setSentToServer(boolean sentToServer) {
		this.sentToServer = sentToServer;
	}



	public UserEvent() {
		setState(EventState.CREATED);
	}
	
	
	
	@Override
	public String toString() {
		return description + " | " + type + " | " + state + " | " + 
		DateUtil.formatDate(getDateTime(), "dd/MM/yyyy hh:mm:ss") + " | " + 
		" | " + getSource().getDescription();
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public EventType getType() {
		return type;
	}

	public void setType(EventType type) {
		this.type = type;
	}
	
	public EventState getState() {
		return state;
	}
	public void setState(EventState state) {
		this.state = state;
	}

	public int compareTo(UserEvent o) {		
		return toString().compareTo(o.toString());
	}

	public Device getDevice() {
		return getDroidGuideUser().getDevice();
	}	
}